package com.taylor.seckill.rabbitmq;

import com.taylor.seckill.config.RabbitmqConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;

/**
 * @author taylor
 * @Description: 消息的接受者
 * @date 2021/4/17 12:57
 */
@Service
@Slf4j
public class MQReceiver {


    @RabbitListener(queues = RabbitmqConfig.TOPIC_QUEUE_1)
    public void receiverSeckill(Object msg){
        //伪代码处理业务逻辑
        log.info("解析接收到的消息 "+msg);
    }

    @RabbitListener(queues = "queue")
    public void receiver(Object msg){
        log.info("接受消息："+msg);
    }

    @RabbitListener(queues = RabbitmqConfig.FANOUT_QUEUE_1)
    public void receiverFanout1(Object msg){
        log.info("fanoutQueue1接受消息:"+msg);
    }
    @RabbitListener(queues = RabbitmqConfig.FANOUT_QUEUE_2)
    public void receiverFanout2(Object msg){
        log.info("fanoutQueue1接受消息:"+msg);
    }


    @RabbitListener(queues = RabbitmqConfig.DIRECT_QUEUE_1)
    public void receiverDirect1(Object msg){
        log.info("direct route1模式接受消息："+msg);
    }
    @RabbitListener(queues = RabbitmqConfig.DIRECT_QUEUE_2)
    public void receiverDirect2(Object msg){
        log.info("direct route2模式接受消息："+msg);
    }

    @RabbitListener(queues = RabbitmqConfig.TOPIC_QUEUE_1)
    public void receiverTopic1(Object msg){
        log.info("topic 模式(匹配没有或者多个单词)接受消息："+msg);
    }
    @RabbitListener(queues = RabbitmqConfig.TOPIC_QUEUE_2)
    public void receiverTopic2(Object msg){
        log.info("topic 模式(匹配一个单词)接受消息："+msg);
    }
}
